<?php

namespace App\ApiBackend\Workbench;

use App\Http\Controllers\ApiBaseController;
use Illuminate\Support\Facades\DB;


/**
 * 代办列表
 */
class Project extends ApiBaseController
{
  /**
   * 参数检查
   */
  protected function check(): void
  {

  }

  /**
   * 业务主体
   */
  protected function service(): void
  {

    $groupData = [];
    $roleId = request()->user()->roleId;
    $tagColorArr = ['pink', 'red', 'orange', 'green', 'cyan', 'blue', 'purple'];
    switch ($roleId) {
      default:
        $count = mt_rand(1,99);// DB::table("goods")->where('status', 0)->count();
        if ($count > 0) {
          $groupData[] = [
            "title" => '待上架商品',
            "icon" => 'ant-design:audit-outlined',
            "value" => $count,
            "group" => '商品管理',
            "route" => '/goods/manage/page',
            "routeQuery" => (object)['status' => 0],
          ];
        }
        $count = mt_rand(1,99);//DB::table("order")->where('status', 1)->count();
        if ($count > 0) {
          $groupData[] = [
            "title" => '待确认订单',
            "icon" => 'mingcute:package-line',
            "value" => $count,
            "group" => '订单管理',
            "route" => '/order/manage/confirmTodo',
            "routeQuery" => [],
          ];
        }
        $count = mt_rand(1,99);//DB::table("order")->where('status', 3)->count();
        if ($count > 0) {
          $groupData[] = [
            "title" => '待支付订单',
            "icon" => 'carbon:delivery',
            "value" => $count,
            "group" => '订单管理',
            "route" => '/order/manage/payTodo',
            "routeQuery" => [],
          ];
        }
        break;
    }
    foreach ($groupData as $key => &$val) {
      $val['color'] = $tagColorArr[$key % 8];
    }
    $this->result["data"] = $groupData;
  }
}
